import { Component } from '@angular/core';
import {
  AlertController,
  IonicPage,
  LoadingController,
  NavController,
  NavParams,
  Platform,
  ToastController
} from 'ionic-angular';
import {BasePage} from "../BasePage";

/**
 * Generated class for the ShowpdfPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-showpdf',
  templateUrl: 'showpdf.html',
})
export class ShowpdfPage  extends BasePage   {
  displayData: any;
  scale:any=1;
  scaleVal:any=100;
  constructor(public navCtrl: NavController, public navParams: NavParams, public platform: Platform,
              public loadingCtrl: LoadingController,
              public toastCtrl: ToastController,
              public alertCtrl: AlertController) {
    super(platform, loadingCtrl, toastCtrl, alertCtrl);
    this.displayData = this.navParams.data.url;


  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ShowpdfPage');
    this.showLoading(true,'加载中');
  }
  scaleHandler(type){
    if(type =='add'){
      if(this.scaleVal>=200) return
      this.scaleVal +=20;
      this.scale = this.scaleVal/100;
    }else{
      if(this.scaleVal<=100) return
      this.scaleVal -=20;
      this.scale = this.scaleVal/100;
    }


  }
  goBack(){
    this.navCtrl.pop();
  }
  afterLoad(pdf) {
   //console.log('pdf',pdf)
    this.showLoading(false,'');
  }
  progress(e){
    console.log(e)
    if(e.total == undefined){
      this.showLoading(false,'');
      this.showToast('文件错误');
    }
  }
  onError(err){
    console.log(err)
    this.showLoading(false,'');
  }

}
